package com.b511.swpu.cementbackend.controller;

import com.b511.swpu.cementbackend.dto.input.BoreholeConditionInputDto;
import com.b511.swpu.cementbackend.entity.FormationTemperature;
import io.swagger.annotations.Api;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;
import com.b511.swpu.cementbackend.util.R;
import com.b511.swpu.cementbackend.service.FormationTemperatureService;

@Api(value = "地层温度", tags = {"地层温度"})
@RestController
@RequestMapping("/formation_temperature")
public class FormationTemperatureController {

    public final FormationTemperatureService formationTemperatureService;

    public FormationTemperatureController(FormationTemperatureService formationTemperatureService){
        this.formationTemperatureService = formationTemperatureService;
    }

    @GetMapping("/{num}/{size}")
    public R getFormationTemperature(@PathVariable int num, @PathVariable int size,  @ModelAttribute BoreholeConditionInputDto boreholeConditionInputDto) {
        return formationTemperatureService.getFormationTemperatureByCondition(boreholeConditionInputDto, PageRequest.of(num, size));
    }

    @PutMapping("/{id}")
    public R updateFormationTemperature(@PathVariable Long id, @RequestBody FormationTemperature formationTemperature){
        return formationTemperatureService.updateFormationTemperature(id,formationTemperature);
    }

    @DeleteMapping("/{id}")
    public R deleteFormationTemperature(@PathVariable Long id){
        return formationTemperatureService.deleteFormationTemperature(id);
    }
}
